<template>
	<view>
		<text>http 请求</text>
		<button @click="fetchData">请求数据</button>
		<button @click="getToken">获取token</button>
		<ka-button types="type_from_father" @onBtnClick="handleBtnClcik">
			<view class="insert">插槽</view>
			<template #footer>
				<view>我是footer</view>
			</template>
		</ka-button>
		<button>调用子组件方法</button>
	</view>
</template>

<script>
import KaRequest from '@/service/index.js';
export default {
	data() {
		return {};
	},
	methods: {
		handleBtnClcik(e) {
			console.log('父组件接受事件', e);
		},
		fetchData() {
			console.log('数据请求~');
			uni.setStorage({
				key: 'token',
				data: 'token 的值'
			});

			KaRequest.get('/home/multidata', { age: 18 }).then(res => {
				console.log(res);
				uni.setStorage({ key: 'data-shop', data: res.data });
			});
			// KaRequest.post('/customer/site/listSite').then(res =>
			// 	console.log(res)
			// );
			// uni.request({
			// 	url: 'http://152.136.185.210:7878/api/hy66/home/multidata',
			// 	success(res) {
			// 		console.log(res.data.data);
			// 	}
			// });
		},
		getToken() {
			let value = uni.getStorageSync('token');
			console.log(value, 'token value');
		}
	}
};
</script>

<style></style>
